package com.yangguang.huahui.mvp.presenter;

import com.yangguang.huahui.entity.DataInfo;
import com.yangguang.huahui.mvp.model.CommonModel;
import com.yangguang.huahui.mvp.view.CollectionListView;
import com.yangguang.huahui.rx.RxManager;
import com.yangguang.huahui.rx.RxSubscriber;

import java.io.IOException;

import okhttp3.ResponseBody;

/**
 * Created by Administrator on 2017/4/18.
 */

public class CollectionListPresenter extends BasePresenter<CollectionListView>{
    CommonModel model;

    public CollectionListPresenter() {
        model = new CommonModel();
    }
    public void getCollections(String uid, int type){
        mSubscription = RxManager.getInstance().doSubscribe(model.getCollections(uid, type), new RxSubscriber<ResponseBody>(false) {
            @Override
            protected void _onNext(ResponseBody responseBody) {
                try {
                    mView.onSuccess(responseBody.string());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            protected void _onError() {
                mView.onError();
            }
        });
    }
}
